/**
 * Created by YY on 2016/9/9.
 */
angular.module('teacher')
  .factory('teacherFactory', function (Name, Url, $http, $log) {
    var courseList;
    var currentCourse;
    var self = {};
    self.getName = function (callback) {
      Name.getName(function (data) {
        callback(data);
      })
    };
    self.getCourseList = function (callback) {
      if (courseList) {
        $log.info('courseList by Cache');
        callback(courseList);
      } else {
        $http.get(Url('teacher-side/course-list')).then(function (data) {
          $log.info('courList by ajax');
          courseList = data;
          callback(data);
        });
      }
    };
    self.setCurrentCourse = function (value) {
      currentCourse = value;
    };
    self.getCurrentCourse = function () {
      return currentCourse;
    };
    return self;
  });